package service.impl;

import dao.ProductDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import pojo.Product;
import service.ProductService;
import util.CommonResult;

@Service
public class ProductServiceImpl implements ProductService {
    @Autowired
    private ProductDao productDao;

    @Override
    public CommonResult getAllProductById(Integer id) {
        Product product = productDao.getAllProductById(id);
        if (product != null) {
            return new CommonResult(product);
        }
        return new CommonResult();
    }

    @Override
    public CommonResult getAllProduct() {
        return new CommonResult(productDao.getAllProduct());
    }
}
